{
  "properties" : { },
  "id" : "4fbe794930fc4540a68efb5ea7edbfc2",
  "script" : null,
  "groupId" : "f65c3f8b5be64dea8331b33939d3b2a0",
  "name" : "巡检结果图表模式",
  "createTime" : 1727071100268,
  "updateTime" : 1724915869930,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "queryCount",
  "method" : "POST",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "{\r\n\r\n\"taskId\" :  \"1819188656790945793\",\r\n\"updateTime\" :  \"2024-08-23 17:17:10\"\r\n\r\n}",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": \"Hello magic-api\"\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
// //taskId
// : 
// "1819188656790945793"
// updateTime
// : 
// "2024-08-23 17:17:10"

var sql="""
      SELECT A.ruleName,
               SUM ( CASE WHEN DEVICE_TYPE = 1 AND RESULT = '1' THEN 1 ELSE 0 END ) qualifiedrouter,
               SUM ( CASE WHEN DEVICE_TYPE = 2 AND RESULT = '1' THEN 1 ELSE 0 END ) qualifiedSwitch,
               SUM ( CASE WHEN DEVICE_TYPE = 1 AND RESULT = '0' THEN 1 ELSE 0 END ) unqualifiedRouter,
               SUM ( CASE WHEN DEVICE_TYPE = 2 AND RESULT = '0' THEN 1 ELSE 0 END ) unqualifiedSwitch
        FROM
            (
                SELECT
                    ar.NAME ruleName,
                    d.DEVICE_TYPE,
                    r.RESULT
                FROM
                    ndmp_audit_result r
                        LEFT JOIN ndmp_device d ON r.device_id = d.
                        ID LEFT JOIN ndmp_audit_rule ar ON r.rule_id = ar.ID
                WHERE
                    r.task_id =  #{body.taskId}
                  and r.UPDATE_TIME = #{body.updateTime}
            ) A
        GROUP BY
            ruleName
"""
return db.select(sql) 